
// <copyright file="EmptyRecordFilter.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The empty record filter.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Data
{
    using System;
    using System.Data;

    using SubhadraSolutions.Sharp.Utils.Collections.Generic;

    /// <summary>
    /// The empty record filter.
    /// </summary>
    public sealed class EmptyRecordFilter : IFilter<IDataRecord>
    {
        #region Static Fields

        /// <summary>
        /// The instance.
        /// </summary>
        private static readonly EmptyRecordFilter InstanceObject = new EmptyRecordFilter();

        #endregion Static Fields

        #region Constructors and Finalizers

        /// <summary>
        /// Prevents a default instance of the <see cref="EmptyRecordFilter"/> class from being created.
        /// </summary>
        private EmptyRecordFilter()
        {
        }

        #endregion Constructors and Finalizers

        #region Public Properties

        /// <summary>
        /// Gets the instance.
        /// </summary>
        public static EmptyRecordFilter Instance
        {
            get
            {
                return InstanceObject;
            }
        }

        #endregion Public Properties

        #region Public Methods and Operators

        /// <summary>
        /// The should filter.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool ShouldFilter(IDataRecord obj)
        {
            for (int i = 0; i < obj.FieldCount; i++)
            {
                object o = obj[i];
                if (o != null && o != DBNull.Value)
                {
                    return true;
                }
            }

            return false;
        }

        #endregion Public Methods and Operators
    }
}